#include <stdio.h>

#include "tlib_lck.h"
	
int main( void )
{
	int  i = 0;
	
	int nRc;
	
	tagTlibLckHandle  *pTlibLckHandle;

	nRc = Tlib_Lck_Create( 10000, &pTlibLckHandle );
	
	printf( "1. %d %d %d\n", nRc, pTlibLckHandle->nSemKey, pTlibLckHandle->nSemID );
	
	while ( 1 )
	{
		i = getchar();
		
		switch( i )
		{
			case '1':
				nRc = Tlib_Lck_EnterShare( pTlibLckHandle );
				printf( "EnterShare. %d\n", nRc );
				break;
				
			case '2':
				nRc = Tlib_Lck_LeaveShare( pTlibLckHandle );
				printf( "LeaveShare. %d\n", nRc );
				break;
				
			case '3':
				nRc = Tlib_Lck_EnterExclusive( pTlibLckHandle );
				printf( "EnterExclusive. %d\n", nRc );
				break;
				
			case '4':
				nRc = Tlib_Lck_LeaveExclusive( pTlibLckHandle );
				printf( "LeaveExclusive. %d\n", nRc );
				break;
				
			case 'q':
			   nRc = Tlib_Lck_Destroy( pTlibLckHandle );
				printf( "Destroy. %d\n", nRc );
			   return 0;
			   
			case 'd':
				nRc = Tlib_Lck_Dump( pTlibLckHandle );
				break;
		}
		
	}

}
	
